APIs are becoming ubiquitous, but they are really hard to design well. In this talk, we'll discuss how to design and implement an API that isn't just functional, but makes people stand up and cheer. We'll also cover tips for integrating with other people's APIs.
But an awesome API isn't just a feature. APIs are currently transforming the world, just like open source software has changed the world for the last decade. We'll talk about how this transformation impacts developers and changes the rules.
This talk was originally given at LA RubyConf in February 2011.
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
Advanced API Design: how an awesome API can attract friends, make you rich, and change the world
1. Advanced API Design
How an awesome API can
attract friends,
make you rich,
and change the world
Jon Dahl
@jondahl
jon@zencoder.com
Monday, May 23, 2011
2. Application
Programming
Interface
Monday, May 23, 2011
37. 200 OK
201 Created
202 Accepted
400 Bad Request
401 Unauthorized
402 Payment Required
404 Not Found
409 Conflict
418 I’m a teapot
422 Unprocessable Entity
500 Internal Server Error
503 Service Unavailable
Monday, May 23, 2011
44. HTTP/1.1 401 Unauthorized
{
"errors": [
"api_key not found.",
"api_key may not include spaces."
]
}
Monday, May 23, 2011
45. HTTP/1.1 401 Unauthorized
{
"errors": [
"api_key not found. Please log in to https://
example.com/account/api to retrieve your API
key.",
"api_key may not include spaces."
]
}
Monday, May 23, 2011
46. POST /api/user HTTP/1.1
Accept: application/json
Content-Type: application/json
{
"api_key" : "A23B92F281CC"
"strength" : 18
}
Monday, May 23, 2011
56. Zencoder::API.define_setting :audio_channels, :section => section
do |z|
z.tip = "The number of audio channels: 1 or 2."
z.description = %Q{
<p>The number of audio channels to use: 1 (mono) or 2
(stereo).</p>
<p>Note that mono AAC audio sometimes erroneously self-reports
as stereo when inspected. We recommend using iTunes to get the true
number of channels for AAC audio.</p>
}
z.data_type = "Integer"
z.valid = "1 or 2"
z.default = "1 if the original file is mono; otherwise, 2."
z.example = "1"
z.see_also = [:audio_bitrate, :audio_quality]
end
Monday, May 23, 2011
82. "I know the following statement is going to sound dramatic,
but it's the truth. Zencoder seriously uplifted my entire day.
The API is really well designed and has documentation for not
only what each value should be but also what an example
input/output would look like using the value. I had spent the
earlier part of the day working with a web service that is the
complete opposite of those things.
So when I started digging into Zencoder I felt like I was
witnessing a double rainbow. Then when I found the API
Builder, it went beyond a double rainbow to a level I can only
imagine is equal to witnessing a unicorn birth.”
Monday, May 23, 2011